<include file="Public/min-header" />
<div class="wrapper">
	<style type="text/css">
		.navbar{margin-bottom: 0px;}
		#fenlei_box{border: 1px solid #3297ff;position: absolute;width:380px;height:250px;overflow-y: auto; z-index:9999;background:#fff;display:none;margin-left: 38px;}
		#fenlei_box li{list-style: none;color:#3297ff;text-align:center;margin-left:-40px;line-height: 32px;cursor: pointer;padding-left:20px;padding-right:20px;}
	</style>
	<section class="content"> 
       <div class="row"> 
       		<div class="col-xs-12">
	       		<div class="box">
	             <div class="box-header">
	               	<nav class="navbar navbar-default">
				        <div class="collapse navbar-collapse">
				          <form class="navbar-form form-inline"  method="get">
				            <div class="form-group">添加：
				              	<input type="text" id="user_name" name="user_name" value="" class="input-sm" style="width: 380px;text-align: center;" oninput="kehu_sousuo($(this))" autocomplete="off" title="" placeholder="输入添加客户电话">
				              	<ul id="fenlei_box" rel="{$store_id}">
				            </div>
				          </form>
				      	</div>
	    			</nav>
	             </div>
	             <div class="box-body">
	           	 <div class="row">
	            	<div class="col-sm-12">
		              <table id="list-table" class="table table-bordered table-striped dataTable">
		                 <thead>
		                   <tr role="row">
							   <th class="text-center">电话</th>
                               <th class="text-center">客户名称</th>
                               <th class="text-center">浮价</th>
		                  	   <th style="text-align: center;">操作</th>
		                   </tr>
		                 </thead>
						<tbody>
                          
                              <volist name='store_floating' id="vo">
                             <tr class="text-center" role="row">  
							 <td class="text-center" style="padding:0;">{$vo.mobile}</td>
                             <td class="text-center" style="padding:0;">{$vo.company}</td>
                             <td class="text-center" style="padding:0;"><input type="text" onchange="updateStoreFloating('{$store_id}','{$vo.user_id}',this)"   id="floating" value="{$vo.floating}" /> <sapn style="color:red;">%上下浮动百分比</sapn>	</td>
		                     <td class="text-center" style="padding:0;">
		                      	<a class="btn btn-danger" id="shanchu" rel="{$vo.id}">删除</a>
				     		</td>
		                   </tr>
		                  </volist>
		                   </tbody>
		                 <tfoot>
		                 
		                 </tfoot>
		               </table>
	               </div>
	          </div>
              <div class="row">
              	    <div class="col-sm-6 text-left">
              	    	<button class="btn btn-default btn-sm checkbox-toggle"><i class="fa fa-square-o"></i></button>
              	    </div>
                    <div class="col-sm-6 text-right">{$page}</div>
              </div>
	          </div>
	        </div>
       	</div>
       </div>
   </section>
<script type="text/javascript">
$(document).ready(function() {
	$(".box-body #bianji").click(function(){
			var myrel=$(this).attr('rel');
			var myrul='/Admin/Store/store_bianji/store_id/'+myrel;//+myrel;
				layer.open({
				  type: 2,
				  title:'编辑限制区域',
				  shadeClose: true, //点击遮罩关闭
				  skin: 'layui-layer-rim', //加上边框
				  area: ['920px', '620px'], //宽高
				  content: myrul
			})
	    });
		
	 $("body").on("click", function() {
	 	$('body #fenlei_box').hide(100);
	 });
	
	$("body #fenlei_box").on("click","li", function() {
		var ids=$(this).attr('rel'),text=$(this).attr('rev'),id=$(this).parent().attr('rel');
		$.post("/Admin/store/store_userfloating",
		  {
			action:'add',
		    store_id:id,
		    value:ids
		  },
		  function(data,status){
			  setTimeout(function(){
			    location.reload();
			   },1000);
		  });
			
	});
	
	$(".box-body #shanchu").click(function(){
			var del_id=$(this).attr('rel');
			$.post("/Admin/store/store_userfloating",
			  {
				action:'del',
			    del_id:del_id
			  },
			  function(data,status){
			    location.reload();
			});
});
});

var timer;
function kehu_sousuo(obj) {

	if (timer) {
		clearTimeout(timer);
	}

	timer = setTimeout(function () {
		var value = obj.val();
		if ($.trim(user_name) == '')
			return false;

		var dai_type = $("input[type='radio']:checked").val();
		$.ajax({
			type: "POST",
			url: "/index.php?m=seller&c=User&a=search_user",//+tab,
			data: {search_key: value, dai_type: dai_type, store_id: {$store_id}},
			success: function (data) {
				data = JSON.parse(data);
				if (data.code == '200') {
					$('#fenlei_box').show(200);
					$('#add_user').hide(100);
					$('#fenlei_box').html(data.selects);
				} else {
					$('#fenlei_box').hide(100);
					if (dai_type == 2)
						$('#add_user').show(200);

					$('#fenlei_box').html('');
				}
			}
		});
	}, 800);
}

function updateStoreFloating(store_id,user_id,t){
    var value = $(t).val();
    	$.ajax({
			type: "POST",
			url: "/index.php?m=Admin&c=Store&a=updateStoreFloating",//+tab,
			data: { user_id: user_id, store_id: store_id,val:value},
			success: function (data) {
			    if(data.code == 1){
			        layer.msg('更新成功', {icon: 1}); 
			    }else{
			        layer.msg('更新失败', {icon: 1}); 
			    }
				  
			}
		});
}

</script>
</div>
</body>
</html>   
